package nio.socket.block;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * IO阻塞的服务器端实现
 */
public class BlockServer {

    public static void start(int port) {
        try {
            ServerSocket ss = new ServerSocket(port);
            System.out.println("启动服务器....");
            while (!Thread.currentThread().isInterrupted()) {
                Socket client = ss.accept();
                new TimeServerHandler(client).run();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
